#define _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

struct ListNode {
    int val;
    struct ListNode* next;
};

typedef struct ListNode ListNode;
struct ListNode* reverseList(struct ListNode* head) {
    //if (head == NULL)
    //    return head;
    ListNode* pcur = head, * n1, * n2, * n3;
    n1 = NULL; n2 = pcur; n3 = pcur->next;
    while (n2)
    {
        n2->next = n1;
        n1 = n2; n2 = n3;
        if (n3)
        {
            n3 = n3->next;
        }
    }
    return n1;
}